﻿//==============================================================================
// File: IPerTypeDynamicPropertyRegistry.cs
// Created: 2010-05-10
// Author: Piotr Włodek
//==============================================================================
// This file is a part of MAMMOTH project.
// Copyright (C) 2010 AGH University of Science and Technology, Krakow.
// https://caribou.iisg.agh.edu.pl/trac/mammoth
//
// Mammoth is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// Mammoth is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with WpfRcp. If not, see http://www.gnu.org/licenses/.
//==============================================================================

using System;

namespace WpfRcp.PropertyModel.Core
{
    /// <summary>
    /// Represents property scope which discriminates properties by owning type.
    /// </summary>
    public interface IPerTypeDynamicPropertyRegistry
    {
        /// <summary>
        /// Registers dynamic property per type, per dataset instance. 
        /// Enables adding custom properties to types only in context of single 
        /// dataset instance, not affecting other dataset instances.
        /// </summary>
        /// <param name="name">Property name.</param>
        /// <param name="propertyType">Property CLR type.</param>
        /// <param name="owner">Owning type, which belongs to this dataset.</param>
        /// <param name="metadata">Property metadata.</param>
        /// <returns>Newly created <see cref="MetaProperty"/> instance.</returns>
        MetaProperty RegisterDynamic(string name, Type propertyType, Type owner, PropertyMetadata metadata);

        /// <summary>
        /// Registers dynamic property per type, per dataset instance. 
        /// Enables adding custom properties to types only in context of single 
        /// dataset instance, not affecting other dataset instances.
        /// </summary>
        /// <param name="name">Property name.</param>
        /// <param name="propertyType">Property CLR type.</param>
        /// <param name="owner">Owning type, which belongs to this dataset.</param>
        /// <returns>Newly created <see cref="MetaProperty"/> instance.</returns>
        MetaProperty RegisterDynamic(string name, Type propertyType, Type owner);

        /// <summary>
        /// Unregisters dynamic property from type, from dataset instance.
        /// </summary>
        /// <param name="metaProperty"><see cref="MetaProperty"/> instace.</param>
        /// <param name="owner">Owning type, which belongs to this dataset.</param>
        void UnregisterDynamic(MetaProperty metaProperty, Type owner);

        /// <summary>
        /// Unregisters dynamic property from type, from dataset instance.
        /// </summary>
        /// <param name="propertyName">Property name.</param>
        /// <param name="owner">Owning type, which belongs to this dataset.</param>
        void UnregisterDynamic(string propertyName, Type owner);

        /// <summary>
        /// Method that returns all dynamic properties registered per type in the registry, including inherited properties
        /// </summary>
        /// <param name="owner">Owner of properties.</param>
        /// <returns>Returns all dynamic properties registered per type in the registry.</returns>
        MetaPropertyCollection GetDynamicProperties(Type owner);

        /// <summary>
        /// Method that returns all dynamic properties registered per type in the registry.
        /// </summary>
        /// <param name="owner">Owner of properties.</param>
        /// <param name="inherited">Whether to include inherited properties.</param>
        /// <returns>Returns all dynamic properties registered per type in the registry.</returns>
        MetaPropertyCollection GetDynamicProperties(Type owner, bool inherited);
    }
}
